<template>
    <el-tag type="primary"> 待接诊</el-tag>


    <el-table :data="undealRegister" @row-click="rowClick">
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column prop="age" label="年龄"></el-table-column>
        <el-table-column prop="gender" label="性别">
            <template #default="scope">
                {{ translateCode2Name("Gender", scope.row.gender) }}
            </template>
        </el-table-column>
    </el-table>

    <el-tag type="success">已接诊</el-tag>

    <el-table :data="dealRegister" @row-click="rowClick">
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column prop="age" label="年龄"></el-table-column>
        <el-table-column prop="gender" label="性别">
            <template #default="scope">
                {{ translateCode2Name("Gender", scope.row.gender) }}
            </template>
        </el-table-column>
    </el-table>


</template>

<script setup lang="ts" name='RegisterList'>
import { ref, reactive, onMounted, computed } from "vue";
import { service } from "@/utils/request";
import type { Register } from "@/api/common/types";
import { translateCode2Name } from "@/utils/constantsUtils";


const { type, selectRegister } = defineProps<{
    type: string,
    selectRegister: (r: Register) => void
}>()



const registerList = ref<Register[]>([]);


//待接诊  --计算属性
const undealRegister = computed(() => {
    // let array = [];

    // registerList.value.forEach(item => {

    // })
    return registerList.value.filter(item => item.status === '1')
})

//已接诊

const dealRegister = computed(() => {
    return registerList.value.filter(item => item.status != '1')
})
function loadRegisterList() {




    service.get<Register[]>('/doctor/queryRegister', {
        params: {
            type: type
        }
    }).then(respRegisterList => {

        registerList.value = respRegisterList;

    })

}


function rowClick(row: any, column: any) {
    selectRegister(row)

}



onMounted(() => {

    loadRegisterList();


    // //根据 type 显示不同的表格
    // table1.value.push({
    //     name: '张三' + type,
    //     age: 18,
    //     gender: '男'
    // })


    // //根据 type 显示不同的表格
    // table2.value.push({
    //     name: '刘备' + type,
    //     age: 18,
    //     gender: '男'
    // })
})


defineExpose({
    loadRegisterList
})

</script>

<style scoped></style>